import time

from grove.factory import Factory
from grove.temperature import Temper


# temp test
class HighTemp(object):
    def read(self):
        '''
        read temperature
        :return:
        '''
        sensor = Factory.getTemper("MCP9808-I2C")
        sensor.resolution(Temper.RES_1_16_CELSIUS)
        return sensor.temperature


def main():
    print("Insert Grove - I2C-High-Accuracy-Temperature")
    print("  to Grove-Base-Hat any I2C slot")

    sensor = Factory.getTemper("MCP9808-I2C")
    sensor.resolution(Temper.RES_1_16_CELSIUS)

    print('Detecting temperature...')
    while True:
        print('{} Celsius'.format(sensor.temperature))
        time.sleep(1)


if __name__ == '__main__':
    main()
